{% extends base_template %} {% load i18n %} {% load crispy_forms_tags %}{% load xadmin_tags %}{% load fragment_display %} {% load highlight more_like_this %}{% block extrastyle %}{{ block.super }} {% endblock %} {% block bodyclass %}{{ opts.app_label }}{% endblock %} {% block content-nav %}{% endblock %}
{% block extrahead %}
{{ block.super }}
<style>
.nav-tabs > li.active > a{
    background:none;
    color:#ff0000;
}
.list-apps > li{
    padding: 5px 0px;
}
.list-apps > li.active > a{
    color:#ff0000;
}
</style>
{% endblock %}
{% block search %}
{% endblock %}
{% block content %}
{% if not abrowser_agent %}
    <form method="get" action=".">
        <div class="input-group input-group-lg" style="max-width:500px;">
        <span class="input-group-addon">关键词</span>
          <input name="q" class="form-control" type="text" placeholder="搜索" value="{{query}}">
          <span class="input-group-btn">
                <button class="btn btn-flat btn-warning" id="search-btn" type="submit"><i class="fa fa-search"></i>
                </button>
              </span>
        </div>
        <input type="hidden" name="model" value="{{model_name|default:''}}"/>
        <input type="hidden" name="app" value="{{app_name|default:''}}"/>
    </form>
{% endif %}
    <div class="search-body">
    <div class="row">
        <div class="col-md-9">
        <ul class="nav nav-tabs">
        <li role="presentation" {% ifequal model_name None %}class="active"{% endifequal %}><a href="?q={{query}}&app={{app_name}}">全部</a></li>
        {% for m in models %}
            <li role="presentation" {% ifequal m.name model_name  %}class="active"{% endifequal %}><a href="?q={{query}}&model={{m.name}}&app={{app_name}}">{{m.label}}</a></li>
        {% endfor %}
        </ul>
    
    <div class="page-header">
    <h4>搜索关键词：<span class="text-red">{{query}}</span>，{% if paginator %}搜索到<span class="text-red">{{paginator.count}}</span>个结果{% endif %}</h4>
    </div>
    <div class="search-resultlist">
    {% for result in page.object_list %}
        {% with result|search_include as fragment %}
        {% include fragment %}
        {% endwith %}
        {% empty %}
         <dt>没有查询到信息！</dt>
        {% endfor %}
        </div>
    <nav aria-label="...">
    <ul class="pagination">
    {% if page.number > 1 %}<li><a href="?q={{ query }}&amp;page=1">首页</a></li>{% endif %}
    {% if page.has_previous %}<li><a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">&laquo; 上一页</a></li>{% endif %}
    <li><a href="#">第 {{ page.number }} 页 / 共 {{ page.paginator.num_pages }} 页</a></li>
    {% if page.has_next %}<li><a href="?q={{ query }}&amp;page={{ page.next_page_number }}">下一页 &raquo;</a></li>{% endif %}
    {% if page.number < page.paginator.num_pages %}<li><a href="?q={{ query }}&amp;page={{page.paginator.num_pages}}">尾页</a></li>{% endif %}
    </ul>
    </nav>
        </div>
        <div class="col-md-3">
        <h3>选择搜索应用范围</h3>
        <ul class="list-unstyled list-apps">
        {% for app in apps%}
        <li {% ifequal app.app_name app_name%}class="active"{% endifequal %}><a href="?q={{query}}&app={{app.app_name}}">{{app.verbose_name}}</a></li>
        {% endfor %}
        </ul>
        </div>
    </div>
    
</div>
{% endblock %}